home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4356 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  41 lines

  1. Path: news.infi.net!usenet
  2. From: nngis@norfolk.infi.net (Greg DiGiorgio)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: ASCII value of a character
  5. Date: 3 Feb 1996 22:52:17 GMT
  6. Organization: Customer of InfiNet
  7. Message-ID: <4f0ov1$eca@nw002.infi.net>
  8. References: <Pine.SUN.3.91.960202222737.26868B-100000@parsifal.nando.net>
  9. NNTP-Posting-Host: h-lawnmowerman.norfolk.infi.net
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.99.3
  12.  
  13. In article <Pine.SUN.3.91.960202222737.26868B-100000@parsifal.nando.net>, 
  14. pretzel@nando.net says...
  15. >
  16. >How do you find the ascii value of a character?  What I am actually 
  17. >trying to do is read a tab from the keyboard and use it in a switch 
  18. >statement.  If the user hits tab, input a certain variable, etc.  Also, 
  19. >finding ascii values has infinite other uses.
  20. >
  21. >                        Pretzel <pretzel@nando.net>
  22.  
  23. Pretzel,
  24.  
  25. Here's some twisted logic for you...
  26.  
  27. #include <stdio.h>
  28. main () {
  29.     char c;
  30.     printf("Enter a character: ");
  31.     scanf("%1c",c);
  32.     switch (c) {
  33.         case 9: printf("You entered a TAB\n");
  34.             break;
  35.         default:break;
  36.     }
  37. }
  38.  
  39. Greg DiGiorgio
  40.  
  41.